package com.example.provider.mapper;

import com.example.api.bean.Book;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * All rights Reserved, Designed By www.maihaoche.com
 *
 * @Package com.smilebookshop.server.mapper
 * @author: 红雪（hongxue@maihaoche.com）
 * @date: 2019/1/21 4:39 PM
 * @Copyright: 2017-2020 www.maihaoche.com Inc. All rights reserved.
 * 注意：本内容仅限于卖好车内部传阅，禁止外泄以及用于其他的商业项目
 */
@Mapper
public interface BookMapper {

    @Select("select * from book")
    List<Book> listAllBooks();

    @Select("select * from book where book_id = #{0}")
    List<Book> getById(int id);

    @Update("update book set book_name = #{book_name},author = #{author},descri = #{descri},price = #{price} where book_id = #{book_id}")
    int updateBook(Book book);

    @Delete("delete from book where book_id=#{0}")
    int deleteBook(int i);

    @Update("insert book set book_name = #{book_name},author = #{author},descri = #{descri},price = #{price},book_id = #{book_id}")
    int insertBook(Book book);

}
